package it.example.pad;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

public class PadView extends View{
	private final double BUTTON_PAD_RATIO = 0.2;
	private Paint paint;
	public PadView(Context context, AttributeSet attributeSet) {
		super(context,attributeSet);
		paint = new Paint();
	}
	
	@Override
	protected void onDraw(Canvas canvas){
		
		int height=getHeight();
		int width=getWidth();
		int buttonHeight=(int) (height*BUTTON_PAD_RATIO);
		paint.setColor(Color.BLACK);
		canvas.drawRect(0, 0, getWidth(), getHeight(), paint);
		paint.setColor(Color.WHITE);
		canvas.drawLine(width/2, height, width/2, height-buttonHeight, paint);
		canvas.drawLine(0, height-buttonHeight, width, height-buttonHeight, paint);
	}

	public RectEdges sxButtonEdges(){
		return new RectEdges((int)(getHeight()*(1-BUTTON_PAD_RATIO)),getHeight(),0,getWidth()/2);
	}
	public RectEdges dxButtonEdges(){

		return new RectEdges((int)(getHeight()*(1-BUTTON_PAD_RATIO)),getHeight(),getWidth()/2,getWidth());
	}
	public RectEdges padEdges(){
		return new RectEdges(0,(int)(getHeight()*(1-BUTTON_PAD_RATIO)),0,getWidth());
	}

}
